package com.alan.xm.lib.http;

import android.os.Handler;
import android.os.Looper;

import androidx.annotation.NonNull;

import com.alan.xm.lib.http.callback.OnFailureCallback;
import com.alan.xm.lib.http.callback.OnHttpCallback;

public class ThreadHandler {

    public static void handlerFailureCallback(int code, String message, @NonNull OnFailureCallback callback) {
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(() -> callback.onFailure(code, message));
    }

    public static <T> void handlerSuccessCallback(T t, @NonNull OnHttpCallback<T> callback) {
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(() -> callback.onSuccess(t));
    }

}
